/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package lesson10;

/**
 *
 * @author netcracker
 */
public class Lesson6 {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) throws InterruptedException, IncompatibleVectorSizesException{
        IVector vector = new ArrayVector(15);
        WriterThread wt = new WriterThread(vector);
        ReaderThread rt = new ReaderThread(vector);
        //wt.setPriority(Thread.MIN_PRIORITY);
        System.out.println("One by one");
        wt.start();
        wt.join();
        rt.start();
        rt.join();
        
        wt.interrupt();
        rt.interrupt();
        //One by one
        System.out.println("\n\n");
        System.out.println("Write 'n' Read");
        Keeper k = new Keeper(vector);
        k.start();
        
        Thread.sleep(1000);
        // syncronized
        System.out.println("\n\n");
        System.out.println("Syncronized");
        SafeVector safeVector = Vectors.synchronizedVector(vector);
        wt = new WriterThread(safeVector);
        rt = new ReaderThread(safeVector);
        
        wt.start();
        rt.start();
    }
}
